@foreach($posts as $post)
    <div class="list-group-item d-flex justify-content-between">
        <a class="flex-shrink-0 align-self-center mr-2" href="{{route('users.show',\Illuminate\Support\Facades\Auth::user())}}">
            <img src="{{Auth::user()->getAvatar()}}" alt="{{Auth::user()->name}}" width="52" class="img-thumbnail">
        </a>

        <div class="d-flex flex-column px-4 py-2 flex-grow-1">
            <h6 class="text-primary">
                {{$post->user->name}}
                <small class="text-secondary" style="font-size: 12px">
                    {{$post->created_at->diffForHumans()}}
                </small>
            </h6>
            <small class="text-secondary">
                {{$post->content}}
            </small>
        </div>

        @can('destroy',$post)
            <form action="{{route('post.destroy',$post->id)}}" class="align-self-center" method="post" onsubmit="return confirm('您确认要删除吗?')">
                @csrf
                @method('delete')
                <button class="btn btn-sm btn-danger" style="width: max-content">删除</button>
            </form>
        @endcan
    </div>
@endforeach
